<template>
  <bpmn-viewer :wfCode="wfCode" :processInstanceId="processInstanceId" />
</template>

<script>
import bpmnViewer from '@wf/components/bpmnjs/bpmnViewer';
export default {
  name: 'FlowableRunImg',
  components: { bpmnViewer },
  inject: ['getDataFromOthers'],
  props: {
    wfCode: {
      type: String,
      default: ''
    },
    bindInstanceId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      processInstanceId: ''
    };
  },
  mounted() {
    this.getProcessInstanceId();
  },
  methods: {
    getProcessInstanceId() {
      if (this.getDataFromOthers && typeof this.getDataFromOthers == 'function' && this.getDataFromOthers()) {
        if (this.bindInstanceId) {
          this.processInstanceId = this.getDataFromOthers()[`${this.bindInstanceId}`] ?? '';
        } else {
          this.processInstanceId = this.getDataFromOthers().processInstanceId ?? '';
        }
      }
    }
  }
};
</script>
